import request from '@/utils/request'

export const getArticles = params => {
  return request({
    url: 'mp/v1_0/articles',
    method: 'get',
    params
  })
}
export const getArticle = articleId => {
  return request({
    url: `mp/v1_0/articles/${articleId}`,
    method: 'get'
  })
}
/**
 *
 * @param {draft} 是否存为草稿(true为草稿)
 */
export const postArticles = (data, draft = false) => {
  return request({
    url: 'mp/v1_0/articles',
    method: 'post',
    params: {
      draft
    },
    data
  })
}

export const updateArticle = (articleId, data, draft = false) => {
  return request({
    url: `mp/v1_0/articles/${articleId}`,
    method: 'put',
    params: {
      draft
    },
    data
  })
}
export const delArticles = params => {
  return request({
    url: `mp/v1_0/articles/${params}`,
    method: 'delete'
  })
}

// 获取文章频道
export const getArticleChannels = params => {
  return request({
    url: 'mp/v1_0/channels',
    method: 'get',
    params
  })
}
